import request from "@/utils/request";
//新增购物车 /api/order/addShopping
export function addShopping(data) {
  return request({
    url: "/api/order/addShopping",
    method: "post",
    data: data,
  });
}
//购物车列表 /api/order/getShopping
export function getShopping() {
  return request({
    url: "/api/order/getShopping",
    method: "get",
  });
}
//订单列表
export function getOrderList(data) {
  return request({
    url: `/api/order/search?orderStatus=${data.orderStatus}&pageSize=${data.pageSize}&pageNum=${data.pageNum}&key=${data.key}&saleStatus=${data.saleStatus}&startDate=${data.startDate}&endDate=${data.endDate}`,
    method: "get",
  });
}

export function getOrderDetail(id) {
  return request({
    url: `/api/order/details?orderCode=${id}`,
    method: "get",
  });
}
// /api/order/getSale  get
export function getSale(data) {
  return request({
    url: `/api/order/getSale?year=${data.year}&month=${data.month}&day=${data.day}`,
    method: "get",

  });
}
// 立即下单
export function placeOrder(data) {
  return request({
    url: "/api/order/buy",
    method: "post",
    data: data,
  });
}
// 选中计算金额
export function getShoppingMoney(data) {
  return request({
    url: "/api/order/getShoppingMoney",
    method: "get",
    params: data,
  });
}
// 删除购物车 /api/order/delShopping
export function delShopping(data) {
  return request({
    url: "/api/order/delShopping",
    method: "delete",
    data,
  });
}
//购物车选中状态 /api/order/updateShopping
export function updateShopping(ids) {
  return request({
    url: "/api/order/updateShopping?id=" + ids,
    method: "get",
  });
}

// 收货地址

export function consigneeList() {
  return request({
    url: "/api/consignee/consigneeList",
    method: "get",
  });
}



// 新增收货地址
export function addConsignee(data) {
  return request({
    url: "/api/consignee/addConsignee",
    method: "post",
    data
  });
}
//  获取地址
export function getConsignee(id) {
  return request({
    url: `/api/consignee/getConsigneeInfo/${id}`,
    method: "get",

  });
}

// 修改收货地址
export function updateConsignee(data) {
  return request({
    url: "/api/consignee",
    method: "put",
    data
  });
}

// 删除收货地址
export function delConsignee(id) {
  return request({
    url: `/api/consignee/removeConsignee/${id}`,
    method: "delete",
  });
}

// 设置默认信息

export function setDefault(data) {
  return request({
    url: `/api/consignee/updateDefault`,
    method: "post",
    data
  });
}

// 获取默认地址 /api/consignee/getDefault

export function getDefault() {
  return request({
    url: '/api/consignee/getDefault',
    method: "get",
  });
}


//取消订单
export function cancelOrder(id) {
  return request({
    url: `/api/order/saleCancel/?orderId=${id}`,
    method: "get",
  });
}

// /api/order/changeAddress

export function changeAddress(data) {
  return request({
    url: `/api/order/changeAddress`,
    method: "post",
    data
  });
}


export function getProcess(id) {
  return request({
    url: `/api/order/getProcess/?orderId=${id}`,
    method: "get",
  });
}

// 获取偏远地区邮费 /api/order/remoteArea

export function remoteArea(address) {
  return request({
    url: `/api/order/remoteArea/?address=${address}`,
    method: "get",
  });
}


export function adminSearch(data) {
  return request({
    url: `/api/order/adminSearch?pageSize=${data.pageSize}&pageNum=${data.pageNum}&key=${data.key}`,
    method: "get",
  });
}

// /api/order/check

export function checkOrder(data) {
  return request({
    url: `/api/order/check`,
    method: "post",
    data
  });
}
